package com.metaq.producter;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.taobao.metamorphosis.client.extension.spring.MessageBuilder;
import com.taobao.metamorphosis.client.extension.spring.MetaqTemplate;

/**
 * 发送
 * @author litianyi
 *
 * 2015年10月21日
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:applicationContext-producter.xml" })
public class Sender {
	
	@Resource
	private MetaqTemplate metaqTemplate; 
	
	@Test
	public void send() throws InterruptedException{
		String topic = "test-topic";
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("name", "李四");
		boolean success = metaqTemplate.send(MessageBuilder.withTopic(topic).withBody(map)).isSuccess();
		System.out.println("成功发送..result:"+success);
	}
}
